package cn.edu.zxj.springblog.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description：登录拦截器的注册
 *
 * @author: zxj
 * @date: 2024-02-04
 * @time: 23:51:25
 */
@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {
    private static final List<String> excludePath = Arrays.asList(
            "/user/login",
            "/**/*.html",
            "/css/**",
            "/blog-editormd/**",
            "/js/**",
            "/pic/**"
    );

    @Autowired
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePath);
    }
}
